package innerdemo;

import com.sun.org.apache.bcel.internal.classfile.InnerClass;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-05-13
 * Time:23:52
 */

class OuterClass {
    public int date1 = 1;
    private int date2 = 2;
    public static int date3 = 3;

    /*
     *实例内部类
     *1.实例内部类中不能定义静态的成员变量
     *2.实例内部类当中不能定义静态的成员方法
     *3.如何实例化，实例化内部类
     *         外部类类名.内部类       变量       = 外部类引用.new 内部类();
     *         OuterClass.InnerClass innerClass = out.new InnerClass();
     */
     class InnerClass{
        public int date4 = 4;
        public int date5 = 5;
        //public static int date6 = 6;error

        private InnerClass(){
            System.out.println("实例内部类的构造方法！");
        }

        public void innerFunc(){
            System.out.println("实例内部类的普通方法！");
        }
        //不能
        //public static void staticFunc(){
        //   error
        //}
    }
}

public class Test {

    public static void main(String[] args) {
        OuterClass out = new OuterClass();
        //先要有外部类的对象，通过外部类的对象来调用
        OuterClass.InnerClass innerClass = out.new InnerClass();
    }
}

